<?php
namespace app\index\controller;

use think\Request;

//提现
class Cashout extends Common{
	
	//进入提现页面
	public function index(){
		
		$req = Request::instance();
		
		if($req->isPost()){
			//执行提现
			$pm = [
				'agentid' => AGENT_ID,
				'repaccounttype' => $req->param('accounttype'),
				'repaccount' => $req->param('accountid'),
				'xjtxnum' => $req->param('amount',0,'floatval'),
			];
			$res = \ServerHelper::post('cashout_index_do',$pm);
			$data = $this->J($res);
			ajax($data['msg'],$data['flag'] == 1);
			
		}else{
		
			$pm = [
				'agentid' => AGENT_ID
			];
			$res = \ServerHelper::post('cashout_index',$pm);
			$data = $this->J($res);
			return view('',$data['data']);
		}
	}
	
	
	//提现记录和动作
	public function record(){
		$req = Request::instance();
		
		$pm = [
			'agentid' => AGENT_ID,
			'status' => $req->param('status',-1,'intval'),
			'page' => $req->param('page',1,'intval'),
		];
		$res = \ServerHelper::post('cashout_record',$pm);
		$data = $this->J($res);
		return view('',$data['data']);
	}
	//取消申請
	public function cancel(){
		//$one['buttons'] = __order_status_btns($v['Status']);
		/*
@七歌工作室 高兄，奖励提现，取消接口
api/reward/inrewardcancel.tsl

参数：
agentid
orderid
		*/
		
		$req = Request::instance();
		$pm = [
			'agentid' => AGENT_ID,
			'orderid' => $req->param('orderid')
		];
		$res = \ServerHelper::post('^/reward/inrewardcancel',$pm);
		$data = $this->J($res);
		
		if(empty($data['flag'])){ ajax($data['msg']); }
		ajax($data['msg'],true);
		
	}
	

}
